<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML>
<html>
  <head>
    <c:import url="_meta.jsp"></c:import>
    <c:import url="_link.jsp"></c:import>
    <title>修改密码</title>
  </head>
  
  <body>
    <article class="cl pd-20">
	  <form class="form form-horizontal" id="form-add">
		<div class="row cl">
		  <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>旧密码：</label>
		  <div class="formControls col-xs-8 col-sm-9">
			<input type="password" class="input-text" placeholder="不修改请留空" name="loginpassword" id="loginpassword">
		  </div>
		</div>
		<div class="row cl">
		  <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>新密码：</label>
		  <div class="formControls col-xs-8 col-sm-9">
			<input type="password" class="input-text" placeholder="不修改请留空" name="newPassword" id="newPassword">
		  </div>
		</div>
        <div class="row cl">
          <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>确认密码：</label>
          <div class="formControls col-xs-8 col-sm-9">
            <input type="password" class="input-text" placeholder="不修改请留空" name="newPassword2" id="newPassword2">
          </div>
        </div>
		<div class="row cl">
		  <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
			<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
		  </div>
		</div>
	  </form>
    </article>
    <c:import url="_footer.jsp"></c:import>
    <script type="text/javascript" src="${pageContext.request.contextPath}/resources/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/resources/lib/laypage/1.2/laypage.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/resources/lib/jquery.validation/1.14.0/jquery.validate.js"></script> 
    <script type="text/javascript" src="${pageContext.request.contextPath}/resources/lib/jquery.validation/1.14.0/validate-methods.js"></script> 
    <script type="text/javascript" src="${pageContext.request.contextPath}/resources/lib/jquery.validation/1.14.0/messages_zh.js"></script>
    <script type="text/javascript">
$(function(){
	$("#form-change-password").validate({
		rules:{
			loginpassword:{
				required:true,
				minlength:6,
				maxlength:16
			},
			loginpassword2:{
				required:true,
				minlength:6,
				maxlength:16,
				equalTo: "#loginpassword2"
			},
		},
		submitHandler: function(form) {
			var formData = new FormData($("#form-change-password")[0]);
			$.ajax({
				type: "post",
				url: "${pageContext.request.contextPath}/sysusr/updatePassword",
				data: formData,
				dataType: "json",
				cache: false,
				async:false,
				processData: false,
				contentType: false,
				success: function(data) {
					if(data == 'success') {
						parent.layer.alert(data);
					} else {

					}
				},
				error: function(XMLHttpRequest, textStatus, errorThrown) {
					alert(errorThrown);
					return false;
				}
			});
			return false;
		}
	});
});
    </script>
  </body>
</html>